package com.soft.face.controller;

import com.soft.face.entity.dto.LoginDTO;
import com.soft.face.global.BusinessException;
import com.soft.face.global.R;
import com.soft.face.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "授权")
@RestController
@RequestMapping("login")
@AllArgsConstructor
public class LoginController extends BaseController {

    private LoginService loginService;

    @PostMapping
    @ApiOperation("登录")
    public R<String> login(@RequestBody LoginDTO dto) throws BusinessException {
        return R.success(loginService.login(dto.getUsername(), dto.getPassword()));
    }


}
